/*
 * @Description: 租户信息 - 接口
 * @Author: DSY
 * @Date: 2022-03-14 21:16:02
 * @LastEditors: DHL
 * @LastEditTime: 2023-08-04 14:03:48
 */

import { $get, $post, $put, $exportExcel } from '@/utils/http'
import { ContentTypeEnum } from '@/constant/http'
import {
  TenantInfoListResultModel,
  TenantInfoModel,
  TenantInfoPageParams,
  TenantInfoPageResultModel,
  TenantInfoParams,
  TenantInfoResultModel
} from './model/tenantInfoModel'

/**
 * 分页查询
 */
export const apiTenantInfoSearch = (searchParams: TenantInfoPageParams) =>
  $get<TenantInfoPageResultModel>({
    url: '/sys/twbTenantInfo/search',
    params: searchParams
  })

/**
 * 不分页查询
 * @param searchParams
 * @returns
 */
export const apiTenantInfoSearchList = () =>
  $get<TenantInfoListResultModel>({
    url: '/sys/twbTenantInfo/searchList'
  })

/**
 * 根据ID获取详情
 */
export const apiTenantInfoGetById = (id: string) =>
  $get<TenantInfoResultModel>({
    url: '/sys/twbTenantInfo/getById',
    params: { id: id }
  })

/**
 * 保存信息
 */
export const apiTenantInfoSave = (saveParams: TenantInfoModel) =>
  $post<TenantInfoResultModel>({
    url: '/sys/twbTenantInfo/save',
    contentType: ContentTypeEnum.json,
    params: saveParams
  })

/**
 * 更新信息
 */
export const apiTenantInfoUpdateById = (updateParams: TenantInfoModel) =>
  $put<TenantInfoResultModel>({
    url: '/sys/twbTenantInfo/updateById',
    contentType: ContentTypeEnum.json,
    params: updateParams
  })

/**
 * 根据ID删除信息
 */
export const apiTenantInfoDeleteById = (id: string) =>
  $post<TenantInfoResultModel>({
    url: '/sys/twbTenantInfo/deleteById',
    params: { id: id }
  })

/**
 * 批量删除信息
 */
export const apiTenantInfoBatchDeleteByIds = (ids: string) =>
  $post<TenantInfoResultModel>({
    url: '/sys/twbTenantInfo/batchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 根据ID逻辑删除信息
 */
export const apiTenantInfoLogicDeleteById = (id: string) =>
  $post<TenantInfoResultModel>({
    url: '/sys/twbTenantInfo/logicDeleteById',
    params: { id: id }
  })

/**
 * 批量逻辑删除
 */
export const apiTenantInfoLogicBatchDeleteByIds = (ids: string) =>
  $post<TenantInfoResultModel>({
    url: '/sys/twbTenantInfo/logicBatchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 导出
 * @param searchParams
 * @returns
 */
export const apiTenantInfoExport = (searchParams: TenantInfoParams, fileName: string) =>
  $exportExcel<TenantInfoPageResultModel>(
    {
      url: '/sys/twbTenantInfo/exportExcel',
      params: searchParams
    },
    fileName
  )
